<?php
	include('config.php');
	error_reporting(E_ALL);
	if (version_compare(phpversion(), '5.1.0', '<') == true) { 	
		die ('PHP5.1 Only'); 
	}
	// Constants:
	define('DS', DIRECTORY_SEPARATOR);
	// Get site path
	$site_path = realpath(dirname(__FILE__) . DS . '..' . DS) . DS;
	define ('SITE_PATH', $site_path);
	define('PATH_SMARTY', SITE_PATH.'libs'.DS.'smarty');
	define('PATH_SMARTY_TEMPLATE', SITE_PATH.'templates'.DS.'default');
	define('PATH_SMARTY_COMPILED', SITE_PATH.'tmp'.DS. 'templates_c');
	
	//set constant BASEURL for rewrite url
	$http_home_admin_url = explode("/index.php", $_SERVER['PHP_SELF']);
	$http_home_admin_url = reset($http_home_admin_url);
	$http_home_admin_url = "http://".$_SERVER['HTTP_HOST'].$http_home_admin_url;
	
    define('BASEURL', $http_home_admin_url); 
	// For loading classes
	function __autoload($class_name) 
	{
		//modified to auto load class in model
		$check = explode('_', $class_name);
		$path_to_class='';
		if((count($check)>1)&&(strtolower($check[0])=='model')) {
			$path_to_class='models'.DS.$check[1];
			$filename = str_replace(array('Model_','model_'),'',$class_name). '.php';
		}
		else{
			$path_to_class='classes';
			$filename = strtolower($class_name) . '.php';
		}
		$file = SITE_PATH.$path_to_class.DS. $filename;
		if (file_exists($file) == false) {
			return false;
		}
		include ($file);
	}
	
	$registry = new Registry();
	Application::loadParameters($applicationParameters);

?>